package org.duoyi.striver.service;

import org.duoyi.striver.service.thread.Detection;
import org.duoyi.striver.service.thread.MainRunner;

import java.util.List;

/**
 * 引导应用开始
 */

public class BootstrapService {

    private final MainRunner mainRunner;
    private final Detection detection;

    public BootstrapService(List<TaskChainItem> tasks) {
        this.mainRunner = new MainRunner(tasks);
        this.detection = new Detection(mainRunner);
    }

    public void execute() {
        this.mainRunner.start();
        this.detection.start();
    }

    public void stop() {
        this.mainRunner.setState(false);
        this.mainRunner.stop();
    }
}
